package com.training1.core.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.training1.core.common.controller.BaseController;
import com.training1.core.common.dao.Page;
import com.training1.core.common.entity.RespJson;
import com.training1.core.common.entity.UserEntity;
import com.training1.core.common.global.signIn.LoginInfoUtil;
import com.training1.core.common.utils.StringUtils;
import com.training1.core.entity.MemberEntity;
import com.training1.core.modules.service.LoginService;
import com.training1.core.modules.service.MemberAccountService;
import com.training1.core.modules.service.MemberService;
import com.training1.core.modules.service.SystemUserService;
import com.training1.core.modules.service.UserTestService;

@Controller
@RequestMapping("memberaccount")
public class MemberAccountStatementController extends BaseController{
	
	@Resource
	private SystemUserService systemUserService;
	@Resource
	private MemberService memberService;
	@Resource
	private MemberAccountService accountService;
	
	
	@RequestMapping("accountstatementsetting")
	public String accountstatement(){
		return "huangyan/memberAccountStatementSetting";
	}
	
	/**
	 * 查询开单中心名称
	 * @param f
	 * @return
	 */
	@RequestMapping(value="isOrderCenter",method=RequestMethod.GET)
	@ResponseBody
	public List<UserEntity> find(){
		List<UserEntity> userItems = systemUserService.findAllUserName();
		return userItems;
	}
	/**
	 * 列表查询及赋值
	 * @param f
	 * @return
	 */
	@RequestMapping(value="list",method=RequestMethod.GET)
	@ResponseBody
	public Page<MemberEntity> list(String startTime,String endTime,String name,String memberName,String tel,Page<MemberEntity> page){
		page.getSearch().put("startTime", startTime);
		page.getSearch().put("endTime", endTime);
		page.getSearch().put("branchId", name);
		page.getSearch().put("memberName",memberName);
		page.getSearch().put("cellPhone",tel);
		
		accountService.findNodeAccount(page.getSearch());
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		param.put("branchId", name);
		param.put("memberName",memberName);
		param.put("cellPhone",tel);
		
//		List<MemberEntity> mem = memberService.findNodeAccount(param);
		
		
		return page;
	}
	/**
	 * 导出
	 */
	@RequestMapping("export")
	@ResponseBody
	public void export(HttpServletResponse resp,String startTime,String endTime,String name,String memberName,String tel){
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		param.put("branchId", name);
		param.put("memberName",memberName);
		param.put("cellPhone",tel);
		accountService.export(resp, param);
	}
	/**
	 * 查询各类资金和
	 * @param f
	 * @return
	 */
	@RequestMapping(value="listSUM",method=RequestMethod.GET)
	@ResponseBody
	public MemberEntity listSUM(String startTime,String endTime,String name,String memberName,String tel,Page<MemberEntity> page){
		
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		param.put("branchId", name);
		param.put("memberName",memberName);
		param.put("cellPhone",tel);
		
		MemberEntity mem = accountService.findSUMList(param);
		
		
		return mem;
	}
}
